package cn.labbook.bluetooth.mapper;

import cn.labbook.bluetooth.common.MyPage;
import cn.labbook.bluetooth.entity.TenantPay;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lonzy
 * @since 2019-03-26
 */
public interface TenantPayMapper extends BaseMapper<TenantPay> {

    @Select("SELECT * from tenant_pay tp LEFT JOIN ammeter at on tp.ammeter_id=at.ammeter_id ${ew.customSqlSegment} ")
    List<TenantPay> geGuestRecharge(@Param("ew") Wrapper<TenantPay> wrapper, MyPage<TenantPay> page);

    @Select("SELECT tp.pay_true_amouont,tp.manager_amount from tenant_pay tp LEFT JOIN ammeter at on tp.ammeter_id=at.ammeter_id ${ew.customSqlSegment}")
    List<TenantPay> getSumPay(@Param("ew") Wrapper<TenantPay> wrapper);

    @Select("select ad.is_intercept from ammeter amm left join admin ad on amm.manager_id = ad.admin_id where amm.ammeter_id = #{ammeterId}")
    Integer getIntercept(@Param("ammeterId") String ammeterId);

}
